package 左哥算法.compare.华中农业;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    // dfn序 + 60个树状数组

    static class BIT {
        int n;
        int[] arr;
        public BIT(int n) {
            this.n = n;
            this.arr = new int[n + 1];
        }
        int query(int p) {
            int r = 0;
            while (p > 0) {
                r += arr[p];
                p -= p & -p;
            }
            return r;
        }
        void update(int p, int d) {
            while (p <= n) {
                arr[p] += d;
                p += p & -p;
            }
        }
    }

    static int gTimestamp = 0;

    static void dfn(int u, int fa, List<Integer> []g, int[] start, int[] end) {
        start[u] = ++gTimestamp;
        for (int v: g[u]) {
            if (v == fa) continue;
            dfn(v, u, g, start, end);
        }
        end[u] = gTimestamp;
    }

    public static void main(String[] args) {
        AReader sc = new AReader();
        int n = sc.nextInt();
        int q = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }

        List<Integer>[]g = new List[n + 1];
        Arrays.setAll(g, x->new ArrayList<>());
        // 1-index
        for (int i = 0; i < n - 1; i++) {
            int u = sc.nextInt(), v = sc.nextInt();
            g[u].add(v);
            g[v].add(u);
        }

        int[] start = new int[n + 1];
        int[] end = new int[n + 1];
        dfn(1, -1, g, start, end);

        BIT[] bits = new BIT[61];
        Arrays.setAll(bits, x -> new BIT(n));
        for (int i = 1; i <= n; i++) {
            int v = arr[i];
            bits[v].update(start[i], 1);
        }


        for (int i = 0; i < q; i++) {
            int op = sc.nextInt();
            if (op == 1) {
                int x = sc.nextInt(), y = sc.nextInt();
                bits[arr[x]].update(start[x], -1);
                arr[x] = y;
                bits[arr[x]].update(start[x], 1);
            } else {
                int x = sc.nextInt();
                int l = sc.nextInt(), r = sc.nextInt();

                long res = 0;
                for (int j = l; j <= r; j++) {
                    res += bits[j].query(end[x]) - bits[j].query(start[x] - 1);
                }
                System.out.println(res);
            }
        }


    }

    static
    class AReader {
        private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        private StringTokenizer tokenizer = new StringTokenizer("");
        private String innerNextLine() {
            try {
                return reader.readLine();
            } catch (IOException ex) {
                return null;
            }
        }
        public boolean hasNext() {
            while (!tokenizer.hasMoreTokens()) {
                String nextLine = innerNextLine();
                if (nextLine == null) {
                    return false;
                }
                tokenizer = new StringTokenizer(nextLine);
            }
            return true;
        }
        public String nextLine() {
            tokenizer = new StringTokenizer("");
            return innerNextLine();
        }
        public String next() {
            hasNext();
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

//        public BigInteger nextBigInt() {
//            return new BigInteger(next());
//        }
        // 若需要nextDouble等方法，请自行调用Double.parseDouble包装
    }

}
